package com.tj.api.rest.config;

import com.tj.api.rest.config.response.OssAppTokenVO;
import com.tj.bo.common.conf.api.ApiResponse;
import com.tj.template.application.oss.OSSTokenService;
import com.tj.template.application.oss.OssAppToken;
import com.tj.template.config.vo.RequestLocalInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

/**
 * @program: binary-option
 * @description
 * @author: binary
 * @create: 2020-06-23 15:56
 **/
@RestController
@RequestMapping("/oss")
public class OssController {

    @Autowired
    private OSSTokenService ossTokenService;

    @RequestMapping(value = "/token/get", method = RequestMethod.POST)
    public ApiResponse<OssAppTokenVO> getOssToken() {
        OSSTokenService.OssAppTokenInfo ossAppTokenInfo = ossTokenService.assumeRole(RequestLocalInfo.getCurrentUser().getUserCode());
        OssAppToken ossAppToken = OssAppToken.translate(ossAppTokenInfo);
        return new ApiResponse<>(new OssAppTokenVO(ossAppToken));
    }
}
